Skip to main content

Check for Upper Triangular

is_triu(input: any[]) : boolean

param input - Any matrix, two-dimensional and square, to test if it's an upper triangular or not

returns: boolean - True if it is upper triangular (recall upper triangular means everything below the diagonal is zero), false otherwise.

This function tests if a square 2d matrix is upper triangular or not. Simply look at the diagonal and see if theres any entry below the diagonal that is non zero. If there is, it is not upper triangular.